//import util from '../common/util.js' 
// 定义一个混入对象
var myMixin = {
	data: function() {
		return {
			baseUrl: this.$util.baseUrl,
			imgServer: this.$util.imgServer
		}
	},
	methods: {
		/* 预览照片 */
		previewImage(e, imageList) { //@click="previewImage($event,['https://iode.jpg'])" data-index="0">
			let index = e.currentTarget.dataset.index;
			/* let list = imageList.map((item, index) => {
				return item.url;
			}); */
			//默认预览data-imgs图片
			console.log(e.currentTarget.dataset.imgs)
			imageList=imageList||(e.currentTarget.dataset.imgs&&e.currentTarget.dataset.imgs.split(","))			
			uni.previewImage({
				current: imageList[index], // 当前显示图片的http链接   
				urls: imageList //要预览的图片列表
			});
		},
		goTo(e) {
			//跳转拦截器
			if(this.beforeGoTo){
				var r=this.beforeGoTo(e)
				if(!r)return r;
			}
			var url = e.currentTarget.dataset.path;
			url && this.$util.goTo(url);
		},
		toUrl(path) {
			return path && path.startsWith("http") ? path : this.imgServer + path;
		},
		reload() {
			this.$util.reload()
		}
	},
	/**
	 * 用户点击分享朋友圈
	 * @param {Object} res
	 */
	onShareTimeline(res) {
		//console.log(res)
		return {
			title:this.title || this.appName,
			path:this.path,
			imageUrl: ''
		}		
	}, 
	/**
	 * 用户点击分享给好友
	 * @param {Object} ops
	 */
	onShareAppMessage: function(ops) {		
		return {
			title: this.title || this.appName,
			path: this.path,
		}	
	}

}
export default myMixin
